package com.atguigu.adapter.objectadapter;

//适配器类
public class VoltageAdapter implements IVoltage5V {
	private Voltage220V voltage220v;//关联关系--聚合

	//通过构造器，传入一个 Voltage220V 实例
	public VoltageAdapter(Voltage220V voltage220v) {
		this.voltage220v = voltage220v;
	}
	
	@Override
	public int output5V() {
		int dstV = 0;
		if(null != voltage220v) {
			//获取到220V电压
			int srcV = voltage220v.output220V();
			System.out.println("使用对象适配器，进行适配~~");
			dstV = srcV / 44; //转成5V
			System.out.println("适配完成，输出的电压为=" + dstV);
		}
		return dstV;
	}

}
